# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=speex
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2rc2
pkgrel=2
pkgdesc="A free codec for free speech (mingw-w64)"
arch=('any')
license=('BSD')
url="http://www.speex.org/"
depends=("${MINGW_PACKAGE_PREFIX}-libogg" "${MINGW_PACKAGE_PREFIX}-speexdsp")
options=('strip' '!libtool' 'staticlibs')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
source=(http://downloads.us.xiph.org/releases/${_realname}/${_realname}-${pkgver}.tar.gz
        01-mingw-winmm.patch)
sha256sums=('caa27c7247ff15c8521c2ae0ea21987c9e9710a8f2d3448e8b79da9806bce891'
            'b8ac3a4af3216f6b2d96f6b909c0595290c8f12f8874a9ab855b8971050aca95')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/01-mingw-winmm.patch

  autoreconf -fiv
}

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
